#coding=utf-8
#Boa:FramePanel:PanelReportTodaySale

import wx
from MyListCtrl import MyListCtrlDaysSale

[wxID_PANELREPORTTODAYSALE, wxID_PANELREPORTTODAYSALEBTNDAYAFTER, 
 wxID_PANELREPORTTODAYSALEBTNDAYBEFORE, wxID_PANELREPORTTODAYSALEDATESTART, 
] = [wx.NewId() for _init_ctrls in range(4)]

class PanelReportTodaySale(wx.Panel):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Panel.__init__(self, id=wxID_PANELREPORTTODAYSALE,
              name=u'PanelReportTodaySale', parent=prnt, pos=wx.Point(347, 119),
              size=wx.Size(934, 651), style=wx.TAB_TRAVERSAL)
        self.SetClientSize(wx.Size(926, 617))
        self.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, u'Arial'))
        self.SetBackgroundColour(wx.Colour(183, 209, 173))

        self.dateStart = wx.DatePickerCtrl(id=wxID_PANELREPORTTODAYSALEDATESTART,
              name=u'dateStart', parent=self, pos=wx.Point(22, 30),
              size=wx.Size(120, 27), style=wx.DP_DROPDOWN)
        self.dateStart.SetLabel(u'2014-04-24')
        self.dateStart.SetValue(wx.DateTimeFromDMY(24, 3, 2014, 0, 0, 0))
        self.dateStart.SetToolTipString(u'dateStart')

        self.btnDayBefore = wx.Button(id=wxID_PANELREPORTTODAYSALEBTNDAYBEFORE,
              label=u'\u524d\u4e00\u5929', name=u'btnDayBefore', parent=self,
              pos=wx.Point(152, 30), size=wx.Size(64, 29), style=0)
        self.btnDayBefore.Bind(wx.EVT_BUTTON, self.OnBtnDayBeforeButton,
              id=wxID_PANELREPORTTODAYSALEBTNDAYBEFORE)

        self.btnDayAfter = wx.Button(id=wxID_PANELREPORTTODAYSALEBTNDAYAFTER,
              label=u'\u540e\u4e00\u5929', name=u'btnDayAfter', parent=self,
              pos=wx.Point(224, 30), size=wx.Size(64, 29), style=0)
        self.btnDayAfter.Bind(wx.EVT_BUTTON, self.OnBtnDayAfterButton,
              id=wxID_PANELREPORTTODAYSALEBTNDAYAFTER)

    def __init__(self, parent):
        self._init_ctrls(parent)
        
        self.myInit()
        
    def myInit(self):
        self.dateStart.SetValue(wx.DateTime.Today())
        
        self.lc = MyListCtrlDaysSale(self)
        self.lc.SetSize(wx.Size(800, 450))
        self.lc.Move(wx.Point(22,110))

        filter = {'date':self.dateStart.GetValue().Format('%Y-%m-%d')}
        self.lc.refresh(filter)

    def OnBtnDayBeforeButton(self, event):
        day = self.dateStart.GetValue()        
        span = wx.DateSpan.Days(1)
        day.SubtractDS(span)
        self.dateStart.SetValue(day)
        
        filter = {'date':self.dateStart.GetValue().Format('%Y-%m-%d')}
        self.lc.refresh(filter)

    def OnBtnDayAfterButton(self, event):
        day = self.dateStart.GetValue()        
        span = wx.DateSpan.Days(1)
        day.AddDS(span)
        self.dateStart.SetValue(day)
        
        filter = {'date':self.dateStart.GetValue().Format('%Y-%m-%d')}
        self.lc.refresh(filter)
        

